package com.hundsun.fcp.common.utils;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;

public class AndroidUtil {
	/**
	 * 获取包信息
	 * @param pContext
	 * @return
	 * @throws PackageManager.NameNotFoundException
	 */
	private static PackageInfo getPackageInfo(Context pContext)
			throws PackageManager.NameNotFoundException {
		return pContext.getPackageManager().getPackageInfo(pContext.getPackageName(), 0);
	}
	
	public static String getUserAgent(Context paramContext)
	  {
	    StringBuilder _StringBuilder = new StringBuilder();
	    try
	    {
	      PackageInfo localPackageInfo = getPackageInfo(paramContext);
	      _StringBuilder.append("FcpPluginSdk/");
	      _StringBuilder.append("1.1.1").append(" (");
	      _StringBuilder.append("Android ").append(Build.VERSION.RELEASE).append("_");
	      _StringBuilder.append(Build.VERSION.SDK_INT).append("; "); 
	      _StringBuilder.append(localPackageInfo.packageName).append("/");
	      _StringBuilder.append(localPackageInfo.versionName).append("_");
	      _StringBuilder.append(localPackageInfo.versionCode).append(")");
	      
	    }
	    catch (Exception localException)
	    {
	    }
	    
	    return _StringBuilder.toString();
	  }
}
